package org.zjx.strategy.impl;

import org.zjx.command.ICommand;
import org.zjx.command.basic.DelayCommand;
import org.zjx.command.game.ClickNpcCommand;
import org.zjx.command.service.AccountCommand;
import org.zjx.core.IWindow;
import org.zjx.state.StateManager;
import org.zjx.strategy.IStrategy;
import org.zjx.util.HwndUtil;

import java.awt.*;
import java.awt.image.BufferedImage;

/**
 * 默认策略
 */
public class DefaultStrategy implements IStrategy {

    @Override
    public ICommand analyze(IWindow window, BufferedImage screenshot, StateManager stateManager) {
        if (stateManager.getAccountState() == null || stateManager.getAccountState().getAccountName() == null) {
            return new AccountCommand(window, stateManager);
        }

        HwndUtil.moveWindow(window.getHwnd(), 0, 0);

        ClickNpcCommand clickNpcCommand = new ClickNpcCommand(window, stateManager, "福寿店老板", "平安福寿店", ClickNpcCommand.ClickNpcType.NPC);
        clickNpcCommand.execute();

//        DialogueNpcCommand dialogueNpcCommand = new DialogueNpcCommand(window, stateManager, Arrays.asList("我要做其他事情","任务","是的，我不做了"));
//        dialogueNpcCommand.execute();

//        DialogueNpcCommand.close(window,stateManager,screenshot);

//        CommandFactory.gameClick(window,stateManager,400,400);

        return new DelayCommand(window, 500);
    }

    public static Rectangle createRect(int x1, int y1, int x2, int y2) {
        return new Rectangle(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
    }

    @Override
    public String getStrategyName() {
        return "DefaultStrategy";
    }

    @Override
    public int getPriority() {
        return 100; // 最低优先级
    }

    @Override
    public boolean isApplicable(IWindow window, BufferedImage screenshot, StateManager stateManager) {
        // 默认策略总是适用
        return true;
    }
}